﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization;

namespace CRMAdminDashboard
{
    /// <summary>
    /// Represent differences between two sets of SystemRoles
    /// </summary>
    [Serializable]
    public class RoleDiffCollection
    {

        #region Properties

        /// <summary>
        /// Names of the roles in the left set, or the one set if this collection is used to contain only one set
        /// </summary>
        public List<string> LeftRoles { get; set; }

        /// <summary>
        /// Names of the roles in the right set
        /// </summary>
        public List<string> RightRoles { get; set; }

        /// <summary>
        /// Differences
        /// </summary>
        public List<RoleDiff> RoleDifferences { get; set; }

        #endregion

        #region Entry Points

        /// <summary>
        /// Needed for the serializer
        /// </summary>
        public RoleDiffCollection() { }

        /// <summary>
        /// Create a collection to compare two sets
        /// </summary>
        public RoleDiffCollection(IEnumerable<SystemRole> leftList, IEnumerable<SystemRole> rightList)
        {
            RoleDifferences = new List<RoleDiff>();

            LeftRoles = new List<string>();
            foreach (Object o in leftList)
            {
                LeftRoles.Add(((SystemRole)o).ToString());
            }

            RightRoles = new List<string>();
            foreach (Object o in rightList)
            {
                RightRoles.Add(((SystemRole)o).ToString());
            }
        }

        /// <summary>
        /// Create a collection to print out one set
        /// </summary>
        public RoleDiffCollection(IEnumerable<SystemRole> list)
        {
            RoleDifferences = new List<RoleDiff>();

            LeftRoles = new List<string>();
            foreach (Object o in list)
            {
                LeftRoles.Add(((SystemRole)o).ToString());
            }
        }

        #endregion

    }
}
